var _n11;
var cc__extends = __extends;
var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var $zqcc_OverallSystem = require("zqcc_OverallSystem");
var def_GameUILayer = function (t) {
  function _ctor() {
    // 确保调用父类构造函数（如果 t 是类的话）
    let e = null !== t && t.apply(this, arguments) || this;

    // 初始化属性
    e.gamePlayNode = null;
    e.layersLabel = null;
    e.boardsLabel = null;
    e.holesLabel = null;
    e.freeNumber = 1;
    e.mianfeiNode = [];
    e.Feibiao = null;
    e.gamePlay = null;

    return e;
  }
  cc__extends(_ctor, t);
  _ctor.prototype.start = function () { };
  _ctor.prototype.init = function (t) {
    this.gamePlay = t;
  };
  _ctor.prototype.initFeibiao = function (t) {
    this.Feibiao = t; // 设置当前飞标
    this.freeNumber = $zqcc_OverallSystem.sers().userSrv.getMianfeidaojuData().cishu; // 获取免费次数

    // 检查是否可以激活节点
    if (this.freeNumber > 0 && this.Feibiao.level <= 1) {
      const totalNodes = this.mianfeiNode.length; // 获取节点总数
      for (let index = 0; index < totalNodes; index++) {
        this.mianfeiNode[index].active = true; // 激活节点
      }
    } else {
      this.freeNumber = 0; // 重置免费次数
    }
  };
  _ctor.prototype.initUI = function () {
    this.gamePlay = this.gamePlayNode.getComponent("GamePlay");
    // 更新总层数
    this.layersLabel.string = `总层数：${this.gamePlay.boardLayer.children.length}`;

    let totalBoards = 0; // 总板子数
    let totalHoles = 0;  // 总洞数

    // 计算总板子数和总洞数
    for (const board of this.gamePlay.boardLayer.children) {
      totalBoards += board.children.length; // 统计板子数
      for (const child of board.children) {
        totalHoles += child.getComponent("Board").holesNode.children.length; // 统计洞数
      }
    }

    // 更新标签显示信息
    this.boardsLabel.string = `总板子数：${totalBoards}`;
    this.holesLabel.string = `总洞数：${totalHoles}`;
  };
  _ctor.prototype.onProp = function (t) {
    if ("btn_clear_tmp" !== targetEvent.target.name || this.Feibiao.target_node.getComponent("TargetMgr").canClear()) {
      // 获取当前关卡，如果不存在则默认为1
      const currentLevel = this.Feibiao.level || 1;

      // 生成事件对象，包含游戏名称、道具名称和当前关卡
      const eventData = {
        game_name: "绳子拼图",
        prop_name: {
          btn_add_tmp: "加孔位",
          btn_remove_board: "清板子",
          btn_clear_tmp: "清孔位",
          unlock_2: "解锁气球",
          unlock_1: "解锁气球"
        }[targetEvent.target.name],
        level: currentLevel
      };

      // 播放点击声音
      $zqcc_OverallSystem.mgrs().soundMgr.playSound("click");

      // 判断是否还有免费次数
      if (this.freeNumber > 0) {
        cc.game.emit(targetEvent.target.name);

        // 隐藏所有免费节点
        const freeNodeList = this.mianfeiNode;
        for (let index = 0; index < freeNodeList.length; index++) {
          freeNodeList[index].active = false;
        }

        // 减少免费次数
        this.freeNumber--;

        // 设置免费道具相关数据
        $zqcc_OverallSystem.sers().userSrv.setMianfeidaojuData({
          cishu: 0
        });
      } else {
        // 加载并展示视频广告
        this.Feibiao.loadAndShowVideoAd(eventData, function () {
          cc.game.emit(targetEvent.target.name);
        });
      }
    } else {
      // 显示无须使用道具的提示信息
      $zqcc_OverallSystem.sers().uiSrv.showMessage("无需使用道具");
    }
  };
  _ctor.prototype.onPintu = function () {
    $zqcc_OverallSystem.mgrs().soundMgr.playBtnSound();
    $zqcc_OverallSystem.sers().uiSrv.showPage("Collection", "CollectionPage");
  };
  cc__decorate([ccp_property(cc.Node)], _ctor.prototype, "gamePlayNode", undefined);
  cc__decorate([ccp_property(cc.Label)], _ctor.prototype, "layersLabel", undefined);
  cc__decorate([ccp_property(cc.Label)], _ctor.prototype, "boardsLabel", undefined);
  cc__decorate([ccp_property(cc.Label)], _ctor.prototype, "holesLabel", undefined);
  cc__decorate([ccp_property], _ctor.prototype, "freeNumber", undefined);
  cc__decorate([ccp_property([cc.Node])], _ctor.prototype, "mianfeiNode", undefined);
  return cc__decorate([ccp_ccclass], _ctor);
}(cc.Component);
exports.default = def_GameUILayer;